package
{
	import flash.display.Sprite;
	import flash.geom.Point;
	
	public class GlobalToLocalTest extends Sprite
	{
		public function GlobalToLocalTest()
		{
			super();
			
			var a:Sprite = create(40,40);
			var b:Sprite = create(20,20);
			addChild(a);
			a.x = 100;
			b.x = 10;
			a.addChild(b);
			var pt:Point = b.localToGlobal(new Point());
			trace(pt);
			pt = b.parent.globalToLocal(pt);
			trace(pt)
			trace(Math.cos(Math.atan(0.5)))
		}
		
		private function create(w:int,h:int):Sprite
		{
			var temp:Sprite = new Sprite();
			temp.graphics.beginFill(Math.random()*0xffffff);
			temp.graphics.drawRect(0,0,w,h);
			temp.graphics.endFill();
			return temp;
		}
	}
}